package top.fengyulou.xiaofeng.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import top.fengyulou.xiaofeng.dto.ExamPaperDto;
import top.fengyulou.xiaofeng.dto.PaperDto;
import top.fengyulou.xiaofeng.mapper.ExamPaperMapper;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author  guochao
 * @date  2022/1/26 0:50
 * @version 1.0
 */
@Service
public class ExamPaperService {

    @Resource
    private ExamPaperMapper examPaperMapper;

    //删除
    public void delete(String[] ids){
        examPaperMapper.delete(ids);
    }

    public List<String> getPaperIdListByExamId(String examId){
        return examPaperMapper.getPaperIdListByExamId(examId);
    }

    //修改阅卷数量
    public void updateMarkingNum(ExamPaperDto examPaperDto) {
        examPaperDto.setUpdateTime(new Date());
        examPaperMapper.updateMarkingNum(examPaperDto);
    }

    //用户试卷列表
    public void userPaperListPage(PaperDto paperDto) {
        //查询数据
        PageHelper.startPage(paperDto.getPageNumber(), paperDto.getPageSize());
        List<PaperDto> list = examPaperMapper.userPaperListPage(paperDto);
        PageInfo<PaperDto> pageInfo = new PageInfo<>(list);

        //返回结果
        paperDto.setTotal(pageInfo.getTotal());
        paperDto.setRows(list);
    }
}
